﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Add_MoneyModel : MonoBehaviour
{
    //按钮
    public GameObject CloseBtn;

    public GameObject GoldBtn;
    public GameObject GoldBtnBg;
    public GameObject RoomCardBtn;
    public GameObject RoomCardBtnBg;
    public GameObject TransfBtn;
    public GameObject TransfBtnBg;
   
    public List<GameObject> goldGoodsBtns;
    public List<GameObject> roomCardGoodsBtns;

    public GameObject payCountBtnJia;
    public GameObject payCountBtnJian;
    public GameObject roomCardBtnJia;
    public GameObject roomCardBtnJian;
    public GameObject transfConfirmBtn;

    public UIInput idInput;
    public UIInput payCountInput;
    public UIInput roomCardInput;

    public GameObject Add_money;
    public GameObject PayForGold;
    public GameObject PayForRoomCard;
    public GameObject TransferAccount;

    private void Awake()
    {
        UIEventListener.Get(CloseBtn).onClick = ButtonClick;
        UIEventListener.Get(GoldBtn).onClick = ButtonClick;
        UIEventListener.Get(RoomCardBtn).onClick = ButtonClick;
        UIEventListener.Get(TransfBtn).onClick = ButtonClick;
        UIEventListener.Get(transfConfirmBtn).onClick = ButtonClick;
        UIEventListener.Get(payCountBtnJia).onClick = ButtonClick;
        UIEventListener.Get(payCountBtnJian).onClick = ButtonClick;
        UIEventListener.Get(roomCardBtnJia).onClick = ButtonClick;
        UIEventListener.Get(roomCardBtnJian).onClick = ButtonClick;

        for (int i = 0; i < goldGoodsBtns.Count; i++)
        {
            UIEventListener.Get(goldGoodsBtns[i]).onClick = ButtonClick;
        }
        for (int i = 0; i < roomCardGoodsBtns.Count; i++)
        {
            UIEventListener.Get(roomCardGoodsBtns[i]).onClick = ButtonClick;
        }
    }

    private void Start()
    {
        
    }

    void ButtonClick(GameObject button)
    {
        if (button.name == "CloseBtn")
        {
            Destroy(Add_money);
        }
        //充值金币界面
        else if (button.name == "GoldBtn")
        {
            GoldBtn.transform.Find("Sprite").gameObject.SetActive(true);
            RoomCardBtn.transform.Find("Sprite").gameObject.SetActive(false);
            TransfBtn.transform.Find("Sprite").gameObject.SetActive(false);
            PayForGold.SetActive(true);
            PayForRoomCard.SetActive(false);
            TransferAccount.SetActive(false);
        }
        //购买房卡界面
        else if (button.name == "RoomCardBtn")
        {
            GoldBtn.transform.Find("Sprite").gameObject.SetActive(false);
            RoomCardBtn.transform.Find("Sprite").gameObject.SetActive(true);
            TransfBtn.transform.Find("Sprite").gameObject.SetActive(false);
            PayForGold.SetActive(false);
            PayForRoomCard.SetActive(true);
            TransferAccount.SetActive(false);
        }
        //转账界面
        else if (button.name == "TransfBtn")
        {
            GoldBtn.transform.Find("Sprite").gameObject.SetActive(false);
            RoomCardBtn.transform.Find("Sprite").gameObject.SetActive(false);
            TransfBtn.transform.Find("Sprite").gameObject.SetActive(true);
            PayForGold.SetActive(false);
            PayForRoomCard.SetActive(false);
            TransferAccount.SetActive(true);
        }
        //充值金币 加载选择支付方式界面
        else if (button.name.Contains("Golds"))
        {
            GameObject PaySelect = NGUITools.AddChild(gameObject,(GameObject)Resources.Load(HallPrafabPath.PaySelect));
        }
        //购买房卡 加载选择支付方式界面
        else if (button.name.Contains("RoomCards"))
        {
            GameObject PaySelect = NGUITools.AddChild(gameObject, (GameObject)Resources.Load(HallPrafabPath.PaySelect));
        }
        //转账金额++
        else if (button.name == "PayCountBtn+")
        {

        }
        //转账金额--
        else if (button.name == "PayCountBtn-")
        {

        }
        //房卡数量++
        else if (button.name == "RoomCardBtn+")
        {

        }
        //房卡数量--
        else if (button.name == "RoomCardBtn-")
        {

        }
        //转账
        else if (button.name == "TransfConfirmBtn")
        {
            if(idInput.value == "" || (payCountInput.value == "" && roomCardInput.value == "")){
                GameObject Transfer = NGUITools.AddChild(gameObject,(GameObject)Resources.Load(HallPrafabPath.Transfer));
            }
        }
    }

}
